package com.gzm.check.utils;

import lombok.Getter;

import java.util.Arrays;

/**
 * 体检数据对应的枚举类(血常规)
 * 首个参数放的是对应的代码值,
 * 使用数组是因为,不同设备上传上来的代码值有可能是不同的例如
 * A设置上传上来的白细胞数代码为A B设备上传的代码值为B ,虽然代码值不同但是对应的值应该是相同的,方便扩展
 * 下列参数均为对象字段名称,用反射获取字段,为之赋值和获取值
 * 第二个参数名为血常规中对应字段的字段名称
 * 第三个字段为对象结果单位
 * 第四个对象为参考值上限
 * 第五个对象为参考值下限
 */
@Getter
public enum BloodRoutineEnum {

    //白细胞数(WBC)	WBC
    WBC(new String[]{"WBC"}, "wbc", "wbcUnit", "wbcUpper", "wbcLower"),
    //血小板数(PLT)	PLT
    PLT(new String[]{"PLT"}, "plt", "pltUnit", "pltUpper", "pltLower"),
    //血红蛋白含量(HGB)	HGB
    HGB(new String[]{"HGB"}, "hgb", "hgbUnit", "hgbUpper", "hgbLower"),
    //红细胞数(RBC)	RBC
    RBC(new String[]{"RBC"}, "rbc", "rbcUnit", "rbcUpper", "rbcLower"),
    //红细胞比积(HCT)	HCT
    HCT(new String[]{"HCT"}, "hct", "hctUnit", "hctUpper", "hctLower"),
    //平均红细胞体积(MCV)	MCV
    MCV(new String[]{"MCV"}, "mcv", "mcvUnit", "mcvUpper", "mcvLower"),
    //平均血红蛋白含量(MCH)	MCH
    MCH(new String[]{"MCH"}, "mch", "mchUnit", "mchUpper", "mchLower"),
    //平均血红蛋白浓度(MCHC)	MCHC
    MCHC(new String[]{"MCHC"}, "mchc", "mchcUnit", "mchcUpper", "mchcLower"),
    //红细胞宽度变异系数(RDW-CV)	RDW-CV
    RDW_CV(new String[]{"RDW-CV"}, "rdwCv", "rdwCvUnit", "rdwCvUpper", "rdwCvLower"),
    //红细胞宽度标准差(RDW-SD)	RDW-SD
    RDW_SD(new String[]{"RDW-SD"}, "rdwSd", "rdwSdUnit", "rdwSdUpper", "rdwSdLower"),
    //淋巴细胞绝对值(LY#)	LY#
    LY1(new String[]{"LY#"}, "lym", "lymUnit", "lymUpper", "lymLower"),
    //淋巴细胞百分比(LY%)	LY%
    LY2(new String[]{"LY%"}, "LYMc", "LYMcUnit", "lymcUpper", "lymcLower"),
    //单核细胞百分比(Mid%)	Mid%
    Mid2(new String[]{"Mid%"}, "Midc", "MidcUnit", "midcUpper", "midcLower"),
    //粒细胞绝对值(GR#)	GR#
    GR1(new String[]{"GR#"}, "gra", "graUnit", "graUpper", "graLower"),
    //粒细胞百分比(GR%)	GR%
    GR2(new String[]{"GR%"}, "GRAc", "GRAcUnit", "gracUpper", "gracLower"),
    //血小板比积(PCT)	PCT
    PCT(new String[]{"PCT"}, "pct", "pctUnit", "pctUpper", "pctLower"),
    //平均血小板体积(MPV)	MPV
    MPV(new String[]{"MPV"}, "mpv", "mpvUnit", "mpvUpper", "mpvLower"),
    //血小板分布宽度(PDW)	PDW
    PDW(new String[]{"PDW"}, "pdwc", "pdwcUnit", "pdwcUpper", "pdwcLower"),
    //中间细胞绝对值(Mid%)	Mid#
    Mid1(new String[]{"Mid#"}, "Midb", "MidbUnit", "midbUpper", "midbLower"),
    // Bas#	嗜碱性粒细胞数目
    Bas1(new String[]{"Bas#"}, "BASOb", "BASObUnit", "basobUpper", "basobLower"),
    //Neu#	中性粒细胞数目
    Neu1(new String[]{"Neu#"}, "NEUTb", "NEUTbUnit", "neutbUpper", "neutbLower"),
    //Eos#	嗜酸性粒细胞数目
    Eos1(new String[]{"Eos#"}, "EOb", "EObUnit", "eobUpper", "eobLower"),
    // Mon#	单核细胞数目
    Mon1(new String[]{"Mon#"}, "MONOb", "MONObUnit", "monobUpper", "monobLower"),
    // Neu%	中性粒细胞百分比
    Neu2(new String[]{"Neu%"}, "NEUTc", "NEUTcUnit", "neutcUpper", "neutcLower");

    /**
     * Lymph#	嗜酸性粒细胞数目
     * //Lymph1(new String[]{"Lymph#"}, "EOb", "EObUnit", "eobUpper", "eobLower");
     * <p>
     * Bas%	嗜碱性粒细胞数目
     * Eos%	嗜酸性粒细胞数目
     * Lymph%	嗜酸性粒细胞数目
     * Mon%	单核细胞百分比
     */

    private String[] code;
    private String fieldName;
    private String fieldNameUnit;
    private String upper;
    private String lower;


    BloodRoutineEnum(String[] code, String fieldName, String fieldNameUnit, String upper, String lower) {
        this.code = code;
        this.fieldName = fieldName;
        this.fieldNameUnit = fieldNameUnit;
        this.upper = upper;
        this.lower = lower;
    }

    public static String getFieldName(String code) {
        for (BloodRoutineEnum c : BloodRoutineEnum.values()) {
            if (Arrays.asList(c.getCode()).contains(code)) {
                return c.fieldName;
            }
        }
        return null;
    }

    public static String getFieldNameUnit(String code) {
        for (BloodRoutineEnum c : BloodRoutineEnum.values()) {
            if (Arrays.asList(c.getCode()).contains(code)) {
                return c.fieldNameUnit;
            }
        }
        return null;
    }

    public static String getLower(String code) {
        for (BloodRoutineEnum c : BloodRoutineEnum.values()) {
            if (Arrays.asList(c.getCode()).contains(code)) {
                return c.lower;
            }
        }
        return null;
    }

    public static String getUpper(String code) {
        for (BloodRoutineEnum c : BloodRoutineEnum.values()) {
            if (Arrays.asList(c.getCode()).contains(code)) {
                return c.upper;
            }
        }
        return null;
    }

}
